package com.at.c02_classloader.linking;

/**
 * 初始化阶段，从上到下，顺序执行
 *
 * @author huangchao E-mail:fengquan8866@163.com
 * @version 创建时间：2024/6/22 19:23
 */
public class ClassInitTest {
    private static int num = 1;

    static {
        num = 2;
        number = 20;
        System.out.println(num);
//        System.out.println(number); // 报错：非法的前向引用
    }

    private static int number = 10; // linking之Prepare：number=0 ---> initial: 20 --> 10

    public static void main(String[] args) {
        System.out.println(num); // 2
        System.out.println(number); // 10
    }
}
